<?php
$this->breadcrumbs = array(
    'Users' => array('index'),
    'Manage',
);
?>
<div class="box">
    <header>
        <h5><i class="icon icon-user"></i> - Manager users</h5>
    </header>
    <div class="box">
	<?php
	if (isset(Yii::app()->session['approve_success']) && Yii::app()->session['approve_success']) {
	    ?>
    	<div class='alert alert-success'><strong>Congratulation!</strong> You have approved successfully.</div>

	    <?php
	    unset(Yii::app()->session['approve_success']);
	}
	?>
	<?php
	$this->widget('bootstrap.widgets.TbGridView', array(
	    'id' => 'user-grid',
	    'dataProvider' => $model->search(),
	    'filter' => $model,
	    'columns' => array(
		array(
		    'name' => 'user_id',
		    'header' => '#',
		    'htmlOptions' => array(
			'width' => 50
		    )
		),
//		'username',
		'email',
		'username',
		array(
		    'name' => 'status',
		    'filter' => User::getStatusRange(),
		    'value' => '$data->getStatusText()'
		),
		array(
		    'name' => 'joined',
		    'type' => 'raw',
		    'value' => function($data) {
			return date('m-d-Y', $data->joined);
		    },
		    'filter' => false
		),
		array(
		    'type' => 'raw',
		    'value' => function($data) {
			if ($data->status != User::STATUS_ACTIVE) {
			    echo "<a href='" . BACKEND_SITE_URL . "user/member/approve/id/" . $data->user_id . "'>Approve</a>";
			}
		    }
		),
		array(
		    'class' => 'bootstrap.widgets.TbButtonColumn',
		    'template' => '{update}{delete}',
		    'buttons' => array(
			'delete' => array(
			    'visible' => '$data->type != "admin"'
			),
		    ),
		)
	    )
	));
	?>
    </div>
</div>